package com.dorm.cj.persistence;

import com.dorm.cj.persistence.io.Resources;
import com.dorm.cj.persistence.sqlSession.SqlSession;
import com.dorm.cj.persistence.sqlSession.SqlSessionFactory;
import com.dorm.cj.persistence.sqlSession.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

public class IPersistenceTest {

    @Test
    public void test() throws Exception {
        InputStream resourceAsSteam = Resources.getResourceAsSteam("sqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsSteam);
        SqlSession sqlSession = sqlSessionFactory.openSession();

        UserMapper userDao = sqlSession.getMapper(UserMapper.class);
        List<User> all = userDao.findAll();
        for (User user1 : all) {
            System.out.println(user1.toString());
        }

    }


}
